import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm'

import { Phone } from './phone.entity'

@Entity({ name: 'people' })
export class People {
    //自增列
    @PrimaryGeneratedColumn()
    id: number
    //普通列
    @Column({
        type: 'varchar',
        length: 50,
        name: 'name'
    })
    name: string

    // 一个人多本书
    @OneToMany(() => Phone, phone => phone.people, { eager: true, cascade: true, onUpdate: 'CASCADE', onDelete: 'CASCADE' })
    phones: Phone[]

}